package com.woniu.controller;

import com.woniu.common.core.domain.AjaxResult;
import com.woniu.dto.OrderDto;
import com.woniu.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 杨光 微信号:tolryg
 * @time 14:06
 */
@RestController
public class OrderController {


    @Autowired
    private OrderService orderService;


    @RequestMapping("/web/queryOrderStatus")
    public AjaxResult queryOrderStatus(String orderId){
        String status = orderService.queryOrderStatus(orderId);
        return AjaxResult.success("ok",status);
    }
    @RequestMapping("web/makeOrder")
    public AjaxResult makeOrder(@RequestBody OrderDto orderDto){

        //检测是否票跟别人冲突
        orderService.checkAvailableTicket(orderDto);

        System.out.println("orderDto = " + orderDto);

        orderService.makeOrder(orderDto);

        return AjaxResult.success();

    }
}
